﻿using CommunityToolkit.Mvvm.ComponentModel;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using XYAC.Framework.MonitorTireMaterialManual.DataExporter;
using XYAC.Framework.MonitorTireMaterialManual.OracleRemoteDB;

namespace XYAC.Framework.MonitorTireMaterialManual.DTO
{
    public partial class SemiSteelTriangleRubberReport : ObservableObject
    {
        [ObservableProperty]
        public int _iD;
        [ObservableProperty]
        public bool? _isDeleted;
        [ObservableProperty]
        public string _userId;

        /// <summary>
        /// 补偿系数
        /// </summary>
        [ObservableProperty]
        private double _compensationCoefficient;
        /// <summary>
        /// 条码号 SERIAL_NUMBER
        /// </summary>
        [ObservableProperty]
        [Description("条码号")]
        private string _serialNumber;

        /// <summary>
        /// 扫描时间
        /// </summary>
        [ObservableProperty]
        [Description("扫描时间")]
        private string _scanedDatetime;
        
        /// <summary>
        /// 规格号
        /// </summary>
        [ObservableProperty]
        [Description("规格号")]
        private string _specName;

        /// <summary>
        /// 实际规格号
        /// </summary>
        [Description("实际规格号")]
        [ObservableProperty]
        private string _specNameInfact;
        /// <summary>
        /// 面积差比
        /// </summary>
        [Description("面积差比")]
        [ObservableProperty]
        private double _totalArea;

        /// <summary>
        /// 总宽标准
        /// </summary>
        [Description("总宽标准")]
        [ObservableProperty]
        private double _totalWidth_Stable;

        /// <summary>
        /// 总宽扫描
        /// </summary>
        [Description("总宽扫描")]
        [ObservableProperty]
        private double _totalWidth_Scan;

        /// <summary>
        /// 三角胶厚度标准
        /// </summary>
        [Description("三角胶厚度标准")]
        [ObservableProperty]
        private double _totalThickness_Stable;

        /// <summary>
        /// 三角胶厚度标准扫描
        /// </summary>
        [Description("三角胶厚度标准扫描")]
        [ObservableProperty]
        private double _totalThickness_Scan;
        /// <summary>
        /// 端点厚度
        /// </summary>
        [Description("端点厚度")]
        [ObservableProperty]
        private double _totalThickness_Points;

        /// <summary>
        /// 拐点厚度标准
        /// </summary>
        [Description("拐点厚度标准")]
        [ObservableProperty]
        private double _angleThickness_Stable;
        /// <summary>
        /// 拐点厚度扫描
        /// </summary>
        [Description("拐点厚度扫描")]
        [ObservableProperty]
        private double _angleThickness_Scan;

        /// <summary>
        /// 拐点厚度标准
        /// </summary>
        [Description("拐点厚度标准")]
        [ObservableProperty]
        public double _angleWidth_Stable;
        /// <summary>
        /// 拐点厚度扫描
        /// </summary>
        [Description("拐点厚度扫描")]
        [ObservableProperty]
        public double _angleWidth_Scan;

        /// <summary>
        /// 机台编号
        /// </summary>
        [Description("机台编号")]
        [ObservableProperty]
        public string _eqp;
        /// <summary>
        /// 最后同步时间
        /// </summary>
        [ObservableProperty]
        public DateTime? _lastSyncDate;
        /// <summary>
        /// 同步状态
        /// </summary>
        [ObservableProperty]
        public Boolean _syncState   = false;
        /// <summary>
        /// 判定结果:是否合格 
        /// </summary>
        [ObservableProperty]
        public string _passStatus= "True";

        /// <summary>
        /// 备注
        /// </summary>
        [ObservableProperty]
        public string _remark;
        /// <summary>
        /// 班次
        /// </summary>
        [ObservableProperty]
        public string _shift;
        /// <summary>
        /// 断面形状
        /// </summary>
        [Description("断面形状")]
        [ObservableProperty]
        public string _crossSectionShape="True";
        [ObservableProperty]
        public float _totalLeftArea;
        [ObservableProperty]
        public float _totalRightArea;
        [ObservableProperty]
        public float _measureArea;
        [ObservableProperty]
        public float _measureLeftArea;
        [ObservableProperty]
        public float _measureRightArea;

        /// <summary>
        /// 将 SemiSteelSideInspectionReport 实例转换为 YB_PROCESS_STEP 实例。
        /// </summary>
        /// <param name="report">要转换的 SemiSteelSideInspectionReport 实例。</param>
        /// <returns>转换后的 YB_PROCESS_STEP 实例。</returns>
        public  YB_PROCESS_STEP ToYB_PROCESS_STEP(DataFile dataFile)
        {
            //var dataFile = DataFile.FromSpecVal(this.SpecVal);

            var processStep = new YB_PROCESS_STEP
            {
                // 映射 SemiSteelSideInspectionReport 的字段到 RECORD16 至 RECORD32
                RECORD190 = this.CompensationCoefficient.ToString("F2"),
                //PLAN_ID = this.PlanId,
                PART_NUMBER = this.SpecName,

                //RECORD122 = this.TotalArea.ToString("F2"),
                //RECORD123 = this.MeasureArea.ToString("F2"),
                //RECORD124 = this.TotalLeftArea.ToString("F2"),
                //RECORD125 = this.MeasureLeftArea.ToString("F2"),
                //RECORD126 = this.TotalRightArea.ToString("F2"),
                //RECORD127 = this.MeasureRightArea.ToString("F2"),

                //总宽设定值
                RECORD128 = this.TotalWidth_Stable.ToString("F2"),
                RECORD129 = this.TotalWidth_Scan.ToString("F2"),

                ////左侧宽设定值
                //RECORD130 = (this.TotalWidth_Stable / 2).ToString("F2"),
                //RECORD131 = Math.Abs(dataFile.XReference - dataFile.MeasureKeys.FirstOrDefault().Coordinate).ToString("F2"),
                ////右侧宽设定值
                //RECORD132 = (this.TotalWidth_Stable / 2).ToString("F2"),
                //RECORD133 = Math.Abs(dataFile.XReference - dataFile.MeasureKeys.LastOrDefault().Coordinate).ToString("F2"),

                RECORD134 = this.AngleWidth_Stable.ToString("F2"),
                RECORD135 = this.AngleWidth_Scan.ToString("F2"),

                RECORD140 = this.TotalThickness_Stable.ToString("F2"),
                RECORD141 = this.TotalThickness_Scan.ToString("F2"),
                RECORD143 = this.TotalThickness_Points.ToString("F2"),
                RECORD144 = this.AngleThickness_Stable.ToString("F2"),
                RECORD145 = this.AngleThickness_Scan.ToString("F2"),
                RECORD159 = this.UserId,
                RECORD160 = this.Shift,//班次
                RECORD161 = this.SpecNameInfact,//实际规格
                RECORD162 = this.Remark,//备注
                RECORD163 = this.PassStatus,//判定结果

                //面积比
                //RECORD160 = this.AreaPercent.ToString("F2"),

                //对称性
                //RECORD161 = this.TotalWidth_Symmetry.ToString("F2"),
                //断面形状
                RECORD164 = this.CrossSectionShape,
                EQP = this.Eqp,
            };
            //this.UpdateProcessStep(processStep, dataFile);
            return processStep;
        }

    }
}
